﻿using System;
using TechTalk.SpecFlow;
using UnityScenarios;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.PageObjects;
using System.Threading;

namespace UnityScenarios
{
    [Binding]
    public class SuccessfulLoginSteps
    {
        [Given]
        public void Given_I_enter_username()
        {
            var ie = ScenarioContext.Current["browser"] as FirefoxDriver;
            ie.FindElement(By.Name("UserName")).SendKeys("FirstLogin24");
        }

        [Given]
        public void Given_I_enter_password()
        {
            var ie = ScenarioContext.Current["browser"] as FirefoxDriver;
            ie.FindElement(By.Id("Password")).SendKeys("Password147");
        }

        [When]
        public void When_I_press_the_Submit_button()
        {
            var ie = ScenarioContext.Current["browser"] as FirefoxDriver;
            ie.FindElement(By.Id("logIn")).Click();
        }

        [Then]
        public void Then_the_dashboard_page_is_displayed()
        {
            var ie = ScenarioContext.Current["browser"] as FirefoxDriver;
            ie.PageSource.Contains("Question1");
            //ie.FindElement(By.Id("Answer1")).Click(); THIS WORKS AS BELOW.
            // Assert.IsTrue(ie.PageSource.Contains("Unity Home")); THIS DOES NOT WORK. FIND OUT THE PURPOSE.

            ie.Close();
            ie.Dispose();
        }
    }
}